package restful.struts2;

import java.util.*;

import javax.servlet.http.*;


public class ResponseWriter {

	private Map<String, Object> properties = new HashMap<String, Object>();

	private CacheControl cacheControl = new CacheControl();

	public ResponseWriter ok() {
		set("status", 200);
		return this;
	}

	private void set(String name, Object value) {
		properties.put(name, value);
	}

	public void write(HttpServletResponse response) {
		response.setStatus(getInt("status"));
		cacheControl.write(response);
	}

	private int getInt(String name) {
		return (Integer) properties.get(name);
	}

	public ResponseWriter noCache() {
		cacheControl.noCache();
		return this;
	}


}
